load('Identification.mat');
%% Key Statistics
ParamLabel      =   struct('RHO_M_dom','$\rho_{M}$',...
                           'RHO_M_ext','$\rho^{*}_{M}$',...
                           'RHO_Y_H','$\rho^{H}_{Y}$',...
                           'Taylor_Pi','$\lambda_{\pi}$',...
                           'Taylor_ir','$\lambda_{i}$',...
                           'Cons_ElasTN','$\theta_{TN}$',...
                           'Cons_ElasHF','$\theta_{HF}$',...
                           'Fin_AdjCost','$\phi$');
StatList        =   {'ir/UIP Dev, $\varepsilon_{m}$','ir/UIP Dev, $\varepsilon_{m^{*}}$',...
                     '$\Delta C_{FI} $, $\varepsilon_{m}$','$\Delta C_{FI} $, $\varepsilon_{m^{*}}$',...
                     'VarDec, FI, $\varepsilon_{m}$', ...
                     'VarDec, RI, $\varepsilon_{y^{*}}$',...
                     'VarDec, FI, $\varepsilon_{m^{*}}$'};
TempFun         =   @(IRF)TempFun_ConsDistIRF(PP,SS,MODEL,EquJac,IRF);
StatMat         =   NaN(length(StatList),Info.Num);
parfor ii=1:Info.Num
    if ~isempty(Result{ii})
        StatMat(:,ii)   =   TempFun(Result{ii});
    end
end 
BenchMarkStat   =   TempFun(Result_Benchmark);
%% Figures
Folder          =   'TableGraphs/Identification/';
mkdir(Folder);
ParamList       =   fieldnames(ParamLabel);
N_col           =   length(ParamList);
N_row           =   size(StatMat,1);
fig_size        =   [N_col,N_row].*[1,1]*1/4; 
fig_gap         =   [0.03,0.03];
fig_VMargin     =   [0.05,0.05];
fig_HMargin     =   [0.05,0.05]; 

fig_SubPlot     =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                         fig_gap,fig_VMargin,fig_HMargin);
Fig             =   FigureSetup(['Identification'],fig_size);
for ii=1:N_col
    vv          =   ParamList{ii};
    for jj=1:N_row
        ax          =   fig_SubPlot((jj-1)*N_col+ii);
        XAxis       =   Info.ValueList.(vv)';
        YAxis       =   StatMat(jj,Info.Idx.(vv));
        LineStyle   =   {'-';'b';2};
        plot(XAxis,YAxis,'-b','LineWidth',2);
        yline(BenchMarkStat(jj),':k','LineWidth',1);
        xline(Info.FixedParam.(vv),':k','LineWidth',1);
        ylabel(StatList{jj},'Interpreter','Latex','FontSize',8); 
        title(ParamLabel.(vv),'Interpreter','Latex','FontSize',8);
        xlim([min(XAxis),max(XAxis)]);
        ylim([min(min(StatMat(jj,:)),BenchMarkStat(jj)),max(max(StatMat(jj,:)),BenchMarkStat(jj))]);
        ax.FontSize =   8;
        ax.XGrid    =   'on'; ax.YGrid  =   'on';
%         ax.XAxis.Exponent   =   0;
%       ax.YAxis.Exponent   =   0;
%         ax.YAxis.TickLabelFormat    =   '%g2';
    end
end